package cn.com.taiji.oospub.wechat.service.impl;

import cn.com.taiji.oospub.wechat.entity.Standard;
import cn.com.taiji.oospub.wechat.mapper.StandardMapper;
import cn.com.taiji.oospub.wechat.service.IStandardService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2020-10-28
 */
@Service
public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> implements IStandardService {

    @Autowired
    private StandardMapper standardMapper;

    @Override
    public IPage<Standard> queryPage(Standard queryModel) {
        Page<Standard> page = new Page<>();
        page.setSize(Long.parseLong(queryModel.getPageSize()));
        page.setCurrent(Long.parseLong(queryModel.getPageNo()));
        page.addOrder(OrderItem.asc("ID"));
        QueryWrapper<Standard> queryWrapper = new QueryWrapper<>(queryModel);
        return standardMapper.selectPage(page, queryWrapper);
    }

    @Override
    public Standard findById(String id) {
        return standardMapper.selectById(id);
    }
}
